// components/activity/activity-create-select/index.js
const componentBehavior = require('../../../behaviors/component');
const { COMPONENT_OPTIONS, TARGET_TYPE } = require('../../../constants/common');
import { ACTIVITY_MENU_LIST } from '../../../constants/activity';

Component({
    behaviors: [componentBehavior],
    options: {
        ...COMPONENT_OPTIONS,
    },
    properties: {
        show: {
            type: Boolean,
            value: false,
        },
        type: {
            type: String,
            value: TARGET_TYPE.brand, // brand 品牌 | store 门店
        },
        info: {
            type: Object,
            value: {},
        },
    },
    observers: {
        'type': function (type) {
            const menuList = ACTIVITY_MENU_LIST.filter(i => i.roleList.indexOf(type) > -1);
            this.setData({ menuList });
        },
    },
    data: {
        menuList: [],
    },
    methods: {
        handleClose() {
            this.setData({
                show: false,
            });
        },
        handleSelect(e) {
            const { type, disabled } = e.currentTarget.dataset;
            if (disabled) return;
            this.triggerEvent('select', type);
            this.handleClose();
        },
    }
})
